from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin

class Profile(models.Model):
    user = models.OneToOneField('auth.User', related_name="profile")
    MALE, FEMALE = 'M', 'F'
    LOCAL, REGIONAL, NACIONAL1, NACIONAL2 = 'LOCAL', 'REGIONAL', \
                'NACIONAL1', 'NACIONAL2'
    choices = (
        (MALE, 'Masculino'),
        (FEMALE, 'Femenino'))
    region_choices = (
        (LOCAL, 'LOCAL'),
        (REGIONAL, 'REGIONAL'),
        (NACIONAL1, 'NACIONAL1'),
        (NACIONAL2, 'NACIONAL2'))
    gender = models.CharField(max_length=1, choices=choices,
                              verbose_name='Genero')
    age = models.PositiveIntegerField(verbose_name='Edad')
    commission = models.FloatField(verbose_name='Comision')
    region = models.CharField(max_length=50, choices=region_choices,
                              verbose_name='Region')
    is_wholesaler = models.BooleanField(default=False, verbose_name='Es mayorista')

admin.site.unregister(User)

class UserProfileInline(admin.StackedInline):
    model = Profile

class UserProfileAdmin(UserAdmin):
    inlines = [ UserProfileInline, ]

admin.site.register(User, UserProfileAdmin)
